package com.gold.rabbitmqdemo.study2;

import com.gold.rabbitmqdemo.util.ConnectionUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class WorkProducer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection= ConnectionUtils.getConnection();
        Channel channel=connection.createChannel();
        String queueName="test_work_queue";
        channel.queueDeclare(queueName,false,false,false,null);

        for (int i = 0; i <50 ; i++) {
            String message="hello"+i;
            System.out.println(" work queue send :"+message);
            channel.basicPublish("",queueName,null,message.getBytes());

            try {
                Thread.sleep(i *20);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }


        }

        channel.close();
        connection.close();


    }

}
